import { defineStore } from "pinia";
import {
  reqCategory1,
  reqCategory2,
  reqCategory3,
} from "../../api/product/attr";
import { categoryResponseForm } from "../../api/product/attr/type";
import { categoryStoreForm } from "./types/type";

const useCategoryStore = defineStore("Category", {
  state: (): categoryStoreForm => {
    return {
      c1Data: [],
      c1Id: "",
      c2Data: [],
      c2Id: "",
      c3Data: [],
      c3Id: "",
      isDisabled: false,
    };
  },
  actions: {
    async getC1() {
      let result: categoryResponseForm = await reqCategory1();
      this.c1Data = result.data;
      // console.log(result);
    },
    async getC2(id: number) {
      let result: categoryResponseForm = await reqCategory2(id);
      this.c2Data = result.data;
    },
    async getC3(id: number) {
      let result: categoryResponseForm = await reqCategory3(id);
      this.c3Data = result.data;
    },
  },
});

export default useCategoryStore;
